package com.sy.auth;

import com.sy.ServiceAuthApplication;
import com.sy.auth.service.SysRoleService;
import com.sy.auth.service.SysUserService;
import com.sy.model.system.SysUser;
import com.sy.vo.system.AssginRoleVo;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;

@SpringBootTest(classes = ServiceAuthApplication.class)
public class testService {

    @Autowired
    SysRoleService sysRoleService;
    @Autowired
    SysUserService sysUserService;

    @Test
    public void test(){
        System.out.println(sysRoleService.list());
    }

    @Test
    public void testDelete(){
        System.out.println(sysRoleService.removeById(10));
    }

    @Test
    public void testSave(){
        SysUser sysUser = new SysUser();
        sysUser.setName("测试保存");
        sysUser.setPassword("1212121");
        sysUser.setPhone("12121212121");
        sysUser.setDeptId(1010L);
        sysUser.setUsername("shangXin");
        System.out.println(sysUserService.save(sysUser));
    }

    @Test
    public void findRolesByUserIdTest(){
        System.out.println(sysRoleService.findRolesByUserId(1L));
    }

    @Test
    public void doAssignTest(){
        AssginRoleVo assginRoleVo = new AssginRoleVo();
        ArrayList<Long> list = new ArrayList<>();
        list.add(1L);
        list.add(2L);
        assginRoleVo.setRoleIdList(list);
        assginRoleVo.setUserId(14L);
        sysRoleService.doAssign(assginRoleVo);

    }

    @Test
    public void getByUserNameTest(){
        SysUser sysUser = sysUserService.getUserByUserName("lisi");
        System.out.println(sysUser);
    }
}
